import Vue from 'vue';
import httpApi from '@/common/http.api.js';
async function wechat_login(params) {
	return new Promise(async (resolve, reject) => {
		let code = ''
		uni.login({
			success: (res) => {
				code = res.code;
			}
		})
		uni.getUserProfile({
			desc: '用于完善会员资料',
			success: async (user) => {
				let params = {
					code:code,
					rawData: user.rawData,
					signature: user.signature,
					encryptedData:user.encryptedData,
					iv:user.iv,
					regcode:uni.getStorageSync('regcode') || ''
				}
				let res = await uni.$u.api.wxapp_login(params)
				if (res.code == 1 || res.code==100) {
					resolve(res); //返回写函数里面你要执行的内容	
				}
				reject(res)
			},
			fail: (res) => {
				console.log(user)
			}
		});
	})
}
export default wechat_login
